home *** CD-ROM | disk | FTP | other *** search
- page,132
- name keyboard_code
- title keyboard.asm -- Procedure to mask input to read
- ;
- ;
- ;
- ;
- keyboard_code segment para public 'code'
- assume cs:keyboard_code
- public keyboard ;pass name to linker
- keyboard proc far ;pascal calls are far
- push bp ;save the base pointer
- cli ;stop interuppts
- lock mov bp,sp ;get the stack offset
- lock mov bx,[bp]+10 ;get addr of string
- lock mov dx,[bp]+8 ;get addr of length
- lock mov si,[bp]+6 ;get number to read max
- mov cx,si ;save the limit for input
- mov di,00 ;start at char number 1
- sti ;start interrupts
- get_key:
- mov ah,0 ;call bios for read service
- int 16h ;call bios
- cmp al,0dh ;see if this is the cr char
- je quit ;exit if so else continue
- mov [bx][di],al ;get char into parm area
- inc di
- mov ah,14 ;load for bios service
- int 10h ;bios service to display and move cursor
- loop get_key ;loop until di=cx=30 or find a cr (0dh)
- quit: ;found the end of line
- mov bx,dx ;get address back of length param
- mov [bx],di ;move number of reads to count
- pop bp ;restore the frame pointer
- ret 6 ;cleanup stack
- keyboard endp
- keyboard_code ends
- end ;end assembly